class Person:
    def __init__(self, name, age,gender):
        self.name = name
        self.age = age
        self.gender = gender
    def introduce(self):
        print("大家好，我的名字是 " + self.name + "我今年" + self.age+"岁了"+",是一位"+self.gender)
class Student(Person):
    def __init__(self, name, age, gender, student_id, grade):
        super().__init__(name, age, gender)
        self.grade = grade
        self.student_id = student_id
        self.course = []
    def intorduce(self):
        print("大家好，我的名字叫 " + self.name + "我是" + self.grade+"年级的学生,我的学号是"+self.student_id)

    def enroll_course(self, course):
        if course not in self.course:
            self.course.append(course)
            course.add_student(self)
            return f"{self.name} 成功选修了 {course.name}课程"
        return f"{self.name} 已经选修了 {course.name}课程"
    def list_course(self):
        if self.courses:
            course_names= [course.name for course in self.courses]
            return f"{self.name}选修的课程有： {', '.join(course_names)}"
        else:
            return f"{self.name}还没有选修任何课程"


class Administrator(Person):
    def __init__(self, name, age, gender, staff_id):
        super().__init__(name, age, gender)
        self.staff_id = staff_id

    def add_course(self, course):
        if course not in self.courses:
            self.courses.append(course)
            return f"{self.name} 添加课程 {course.name} 成功"
        return f"{self.name} 已经添加课程 {course.name}"

    def add_student(self,student_id):
        if student_id not in self.students:
            self.students.append(student_id)
            return f"{self.name} 添加学生 {student_id} 添加成功"
        return f"{self.name} 已经添加学生 {student_id}"

    def add_teacher(self,teacher_id):
        if teacher_id not in self.teachers:
            self.teachers.append(teacher_id)
            return f"{self.name} 添加教师 {teacher_id} 添加成功"
        return f"{self.name} 已经添加教师 {teacher_id}"

    def remove_student(self,student_id):
        if student_id in self.students:
            self.students.remove(student_id)
            return f"{self.name} 删除学生 {student_id} 删除成功"
        return f"{self.name} 没有学生 {student_id}"

    def delete_course(self,course):
        if course in self.courses:
            self.courses.remove(course)
            return f"{self.name} 删除课程 {course.name} 删除成功"
        return f"{self.name} 没有课程 {course.name}"

    def remove_teacher(self,teacher_id):
        if teacher_id in self.teachers:
            self.teachers.remove(teacher_id)
            return f"{self.name} 删除教师 {teacher_id} 删除成功"
        return f"{self.name} 没有教师 {teacher_id}"

    def get_student_info(self,student_id):
        if student_id in self.students:
            student = self.students[student_id]
            return f"学生信息：\n姓名：{student.name}\n年龄：{student.age}\n性别：{student.gender}\n学号：{student.student_id}\n年级：{student.grade}"
        return f"没有找到学生 {student_id}"

    def list_all_students(self):
        students = []
        for student in self.students:
            students.append(student.name)
        return students

    def assign_course_to_student(self,student_id,course):
        if student_id in self.students:
            student = self.students[student_id]
            if course in self.courses:
                if course not in student.courses:
                    student.courses.append(course)
                    return f"{student.name} 成功选修了 {course.name} 课程"
                return f"{student.name} 已经选修了 {course.name} 课程"
            return f"没有找到课程 {course.name}"
        return f"没有找到学生 {student_id}"



    def get_school_statistics(self):
        total_students = len(self.students)
        total_courses = len(self.courses)
        return f"学校共有 {total_students} 个学生， {total_courses} 门课程"

    def generate_student_report(self,student_id):
        report = ""
        for student in self.students:
            report += f"{student.name} 的课程有： {', '.join(student.courses)}\n"

class Grade:
    def __init__(self, name):
        self.name = name
        self.courses = []
        self.students = []
    def add_course(self, course):
        if course not in self.courses:
            self.courses.append(course)
            course.grade = self
            return f"{course.name} 添加到 {self.name} 成功"
        return f"{course.name} 已经添加到 {self.name}"
    def add_student(self, student):
        if student not in self.students:
            self.students.append(student)
            student.grade = self
            return f"{student.name} 添加到 {self.name} 课程成功"
        return f"{student.name} 已经添加到 {self.name} 课程"
    def remove_student(self, student):
        if student in self.students:
            self.students.remove(student)
            student.grade = None
            return f"{student.name} 从 {self.name} 删除成功"
        return f"未能删除成功"
    def remove_course(self, course):
        if course in self.courses:
            self.courses.remove(course)
            course.grade = None
            return f"{course.name} 从 {self.name} 删除成功"
        return f"{course.name} 没有添加到 {self.name}"
    def list_course(self):
        if self.courses:
            course_names = [course.name for course in self.courses]
            return f"{self.name} 的课程有： {', '.join(course_names)}"
        else:
            return f"{self.name} 没有课程"
    def list_student(self):
        if self.students:
            student_names = [student.name for student in self.students]
            return f"{self.name} 的学生有： {', '.join(student_names)}"
        else:
            return f"{self.name} 没有学生"
if __name__ == '__main__':
    student = Student("张三", "18", "男", "2023001", "一年")
    student.introduce()
    student.enroll_course("Python")
    print(student.introduce())
    print(student.list_course())